package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author: wuhong-016
 * @time: 2021/4/12 16:05
 * @version: v1.0.0
 * @description:TODO
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Value("${spring.application.name}")
    private String name;

    @Autowired
    private HealthCheckImpl healthCheck;

    @GetMapping("/version")
    public String version() {
        return "当前服务应用：" + name + "  当前版本：a  服务状态：" + healthCheck.isHealth() + "   " + new Date();
    }

    @GetMapping("/online")
    public String online() {
        healthCheck.setHealth(true);
        return "当前服务应用：" + name + "  当前版本：a  服务状态：" + healthCheck.isHealth() + "   " + new Date();
    }

    @GetMapping("/offline")
    public String offline() {
        healthCheck.setHealth(false);
        return "当前服务应用：" + name + "  当前版本：a  服务状态：" + healthCheck.isHealth() + "   " + new Date();
    }

}